home *** CD-ROM | disk | FTP | other *** search
/ Internet Tools (InfoMagic) / Internet Tools.iso / dos_win / winsock / maillist / 94-05.Z / 94-05 / 000089_fit106@its.csiro.au_Fri May 6 20:23:09 1994.msg < prev    next >
Internet Message Format  |  1994-05-31  |  3KB

  1. Received: from commsun.its.csiro.au by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  2.           id AB20557; Thu, 5 May 1994 20:24:39 -0400
  3. Received: by commsun.its.CSIRO.AU id AA07843
  4.   (5.65c/IDA-1.4.4 for Multiple recipients of list <winsock@sunsite.unc.edu>); Fri, 6 May 1994 10:23:11 +1000
  5. Date: Fri, 6 May 1994 10:23:09 +1000 (EST)
  6. From: Kent Fitch <Kent.Fitch@its.csiro.au>
  7. Sender: Kent Fitch <Kent.Fitch@its.csiro.au>
  8. Reply-To: Kent Fitch <Kent.Fitch@its.csiro.au>
  9. Subject: Re: New Telnet/MUDClient Troubles
  10. To: Chris Rowley <chris@clubside.digex.net>
  11. Cc: Multiple recipients of list <winsock@sunsite.unc.edu>
  12. In-Reply-To: <chris.4.000DFC32@clubside.digex.net>
  13. Message-Id: <Pine.3.89.9405061049.A7127-0100000@commsun.its.CSIRO.AU>
  14. Mime-Version: 1.0
  15. Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  16.  
  17. On Thu, 5 May 1994, Chris Rowley wrote:
  18.  
  19. > >        I am no expert by any means but is it possible to write everything in 
  20. > >Visual Basic? <:-) (maybe a dumb question) Can the interface to winsock (VBX) 
  21. > >be written in VB itself?
  22. > Hi Paul,
  23. >    As visual basic stands, it looks like the answer in no. The hostent data 
  24. > structure (which is used for such, oh, noteworthy functions like 
  25. > gethostbyname, cannot be realized in VB because it contains lists of lists. 
  26.  
  27. At the risk of sounding like a zealot, I think that ALMOST ANYTHING to do 
  28. with WINSOCK can be written in VB.  I have done a basic set of routines 
  29. in VB calling the WINSOCL DLL directly - these worked in blocking mode, 
  30. and I am currently porting them to work in async mode - this would be 
  31. impossible except for the wonderful MSGBLAST.VBX (public domain from 
  32. Microsoft).  Meanwhile, to call the blocking "get host by name", use 
  33. something like this fragment:
  34.  
  35. Type hostent
  36.     h_name_addr As Long
  37.     h_aliases_ptr_addr As Long
  38.     h_addrtype As Integer
  39.     h_length As Integer
  40.     h_addr_list_ptr_addr As Long
  41. End Type
  42.  
  43. Declare Function gethostbyname Lib "winsock.dll" (ByVal hostname As
  44. String) As Long
  45. Declare Sub hmemcpy Lib "Kernel" (dest As Any, src As Any, ByVal n As Long)
  46.  
  47. Function TCPHostLookup (host$) As Long
  48.  
  49.  
  50.     Dim thishost As hostent
  51.     Dim hostptr As Long
  52.     Dim addrp As Long
  53.     Dim addr1 As Long
  54.  TCPHostLookup = 0   ' assume the werst
  55.  
  56.     hostptr = gethostbyname(ByVal host$)
  57.     If hostptr = 0 Then
  58.  
  59.        Debug.Print "lookerr:" & TCPGetErrorMsg()
  60.     Else
  61.         Debug.Print "hostptr="; hostptr
  62.         hmemcpy thishost, ByVal hostptr, 16
  63.         hmemcpy addrp, ByVal thishost.h_addr_list_ptr_addr, 4
  64.         Debug.Print "addrp=", addrp
  65.         If addrp <> 0 Then
  66.             hmemcpy addr1, ByVal addrp, 4
  67.             Debug.Print "final addr=", addr1
  68.             TCPHostLookup = addr1   ' the jackpot
  69.         End If
  70.     End If
  71. End Function
  72.  
  73. Note: TCPGetErrorMsg() just gets the last WS error and decodes into English
  74.  
  75. Goodluck
  76.  
  77. Kent Fitch                           Ph: +61 6 276 6711
  78. ITSB   CSIRO  Canberra  Australia    kent.fitch@its.csiro.au
  79. "We dare not trust our wit for making our house pleasant for our friends,
  80.  so we buy ice-cream"     -  Ralph Waldo Emerson